package com.zhou.base.resilience4j.test;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class CodeGeneratorUpdate {
    private  static String mysqlUrl=
            "jdbc:mysql://rm-d2e60bvmcs6u14zvd.mysql.rds.ops.cmcczzcloud.com:3306/qq_programmer_plan?" +
                    "useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&failOverReadOnly=false&useTimezone=true&serverTimezone=Asia/Shanghai";

    private static String username="qqtest_admin";
    private static String password="admin@123=";

    public static void main(String[] args) {

        FastAutoGenerator.create(mysqlUrl, username, password)
                .globalConfig(builder -> {
                    builder.author("zcy") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride()
                            .outputDir("src\\test\\java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("org.example") // 设置父包名
                            .moduleName("temp") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml,
                                    "src\\test\\resources")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    // 设置需要生成的表名
                    builder.addInclude("programmer_plan_import_student"
                            )
                                          //设置过滤表前缀
                                          .addTablePrefix("programmer_plan_")
                            .entityBuilder().enableLombok();

                })
                .templateConfig(builder -> {
//                    builder.controller("").service("").serviceImpl("").mapper("").mapperXml("");
//                    builder;
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }
}
